package com.library.service;

import com.library.bean.Book;
import com.library.dao.BookDao;
import com.library.util.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;

@Service
public class BookService {
    @Autowired
    private BookDao bookDao;

    public ArrayList<Book> getAllBooks() {
        return bookDao.getAllBooks();
    }

    public ArrayList<Book> getAllBooksByPage( Page page){
        return  bookDao.getAllBooksByPage(page);
    }

    public ArrayList<Book> queryBook(String searchWord) {
        return bookDao.queryBook(searchWord);
    }

    public ArrayList<Book> queryBookByPage(String searchWord,int beginIndex, int everyPage ) {
        return bookDao.queryBookByPage(searchWord, beginIndex, everyPage);
    }

    public ArrayList<Book> queryBook2( long class_id){
        return bookDao.queryBook2(class_id);
    }

    public ArrayList<Book> queryBook2ByPage( long searchWord ,int beginIndex, int everyPage ) {
        return bookDao.queryBook2ByPage(searchWord,beginIndex,everyPage);
    }
    public ArrayList<Class> queryAllClassInfo() {
        return  bookDao.queryAllClassInfo();
    }

    public boolean matchBook(String searchWord) {
        return bookDao.matchBook(searchWord) > 0;
    }

    public boolean addBook(Book book) {
        return bookDao.addBook(book) > 0;
    }

    public Book getBook(Long bookId) {
        return bookDao.getBook(bookId);
    }

    public boolean editBook(Book book) {
        return bookDao.editBook(book) > 0;
    }

    public boolean deleteBook(Long bookId) {
        return bookDao.deleteBook(bookId) > 0;
    }

}
